home *** CD-ROM | disk | FTP | other *** search
/ Interplay's Learn to Program Basic (Review Copy) / Learn to Program Basic Review Copy (Interplay)(June 23, 1998).ISO / pc / ltpbasic / refxmpl / random.bas < prev    next >
BASIC Source File  |  1998-04-07  |  1KB  |  72 lines

  1. Rem This program uses the Random function
  2. Rem to simulate the "paper/scissors/rock" game
  3.  
  4. Dim A$(3)
  5. A$(1) = "Paper"
  6. A$(2) = "Scissors"
  7. A$(3) = "Rock"
  8.  
  9. CLS
  10. Print "Welcome to the game of"
  11. Print "Paper, Scissors, Rock."
  12. Print
  13. Let repeat = 1
  14.  
  15. While repeat = 1
  16.  
  17. Print "Select a number for your choice"
  18. Print "  1.   Paper"
  19. Print "  2.   Scissors"
  20. Print "  3.   Rock"
  21. Input  player
  22. Print "You have selected ";
  23. Print A$(player)
  24.  
  25. Let Computer = Random (1,3)
  26.  
  27. Print "The computer selects ";
  28. Print A$(computer)
  29.  
  30. If player = computer Then
  31. Print "It's a tie!"
  32. Endif
  33.  
  34. If player > computer then
  35. If player + computer <> 4 Then
  36. Print "You win!"
  37. Endif
  38. EndIf
  39.  
  40. If computer > player then
  41. If player + computer <> 4 Then
  42. Print "The computer wins."
  43. Endif
  44. Endif
  45.  
  46. If player > computer then
  47. If player + computer = 4 Then
  48. Print "The computer wins."
  49. Endif
  50. Endif
  51.  
  52. If computer > player then
  53. If player + computer = 4 Then
  54. Print "You win!"
  55. Endif
  56. Endif
  57.  
  58. Print "Want to play again?"
  59. Input answer$
  60. If Left$(answer$,1) = "y" Then 
  61. CLS
  62. Let repeat = 1
  63. Else repeat = 0
  64. Endif
  65.  
  66. Wend
  67. Print "Thanks for playing."
  68. Print "Good-bye to you."
  69. End
  70.  
  71.